package com.bwie.config;

import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title:
 * @BelongProjecet zk3
 * @BelongPackage com.bwie.config
 * @Description:
 * @Copyright 研发一部
 * @Author: Mr.yan
 * @Date: 2024/6/12 10:53
 * @Version V1.0
 */
@Configuration
public class RabbitMqConfig {
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 10:55
     * @param: 创建mq的队列
     * @return null
     */
    @Bean
    public Queue orderQueue(){
        //1.第一个参数是队列的名字
        //2.第二个参数是开启持久化
        return new Queue("orderQueue",true);
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 10:56
     * @param: 创建交换机
     * @return org.springframework.amqp.core.DirectExchange
     */
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("directExchange");
    }
    /**
     * @Description: //TODO
     * @Auther: yanxingru
     * @Date: 2024/6/12 10:57
     * @param: 队列和交换机进行绑定
     * @return org.springframework.amqp.core.Binding
     */
    @Bean
    public Binding orderBind(){
        return BindingBuilder.bind(orderQueue()).to(directExchange()).with("orderBind");
    }

}
